package com.lanou.zhihu.web.controller;

import com.lanou.zhihu.entity.Answer;
import com.lanou.zhihu.entity.User;
import com.lanou.zhihu.service.UserService;
import com.lanou.zhihu.service.User_Message_Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("user_message")
public class User_Message_Controller {
    @Autowired
    public User_Message_Service userMessageService;

    @ResponseBody
    @RequestMapping("/attention")//关注者,
    public int attention( HttpServletRequest request,User user){
        User user1 = (User) request.getSession().getAttribute("user");
        int user2 = userMessageService.attention(user1.getId());
        return user2;
    }


    @ResponseBody
    @RequestMapping("/be_focused")//被关注者,
    public int be_focused( HttpServletRequest request){
        User user1 = (User) request.getSession().getAttribute("user");
        int user2 = userMessageService.be_focused(user1.getId());
        return user2;
    }



    @ResponseBody
    @RequestMapping("/findId")
    public Integer findByQid(String username) {
      Integer id = userMessageService.findByQid(username);
      return id;
    }
}
